package principal;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import persistencia.DAOGenerico;
import janelas.*;
import persistencia.DAOUsuario;
import transporte.TOGenerico;
import transporte.TOUsuario;

public class Principal extends javax.swing.JFrame {
    private Fornecedor fornecedor;
    private Grupo grupo;
    private Subgrupo subgrupo;
    private Area area;
    private Setor setor;
    private Usuario usuario;
    private Patrimonio patrimonio;
    private Transferencia transferencia;
    private Garantia garantia;
    private Emprestimo emprestimo;
    private RelatorioBem relatorioBem;
    private RelatorioTra relatorioTra;
    private RelatorioGar relatorioGar;
    private RelatorioEmp relatorioEmp;
    private Sobre sobre;
    private TermoResponsabilidade termo;
    private Preferencias preferencias;
    private static Login login;
    private static TOUsuario usuarioLogado;
    private JInternalFrame janelaAberta = null;
    private DAOGenerico daoGenerico = new DAOGenerico();
    private DAOUsuario daoUsuario = new DAOUsuario();
    private ArrayList<TOGenerico> situacao;
    private ArrayList<TOGenerico> baixa;
    private ArrayList<TOGenerico> orgao;

    public Principal() throws ParseException {
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            SwingUtilities.updateComponentTreeUI(this);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Erro ao tentar aplicar interface Windows.");
        }
        initComponents();
        iniciarTabelasConstantes();
        iniciarJanelas();
        try {
            setExtendedState(JFrame.MAXIMIZED_BOTH);
        } catch (Exception e) {}
    }

    public static void setUsuarioLogado(TOUsuario usuario) {
        Principal.usuarioLogado = usuario;
    }
    public static TOUsuario getUsuarioLogado() {
        return Principal.usuarioLogado;
    }

    private void iniciarTabelasConstantes() {
        situacao = daoGenerico.selecionarGenerico("situacao", "numero");
        baixa = daoGenerico.selecionarGenerico("baixa", "numero");
        orgao = daoGenerico.selecionarGenerico("orgao", "nome");
    }

    private void iniciarJanelas() throws ParseException {
        fornecedor = new Fornecedor();
        add(fornecedor);
        fornecedor.setVisible(false);
        grupo = new Grupo();
        add(grupo);
        grupo.setVisible(false);
        subgrupo = new Subgrupo();
        add(subgrupo);
        subgrupo.setVisible(false);
        area = new Area();
        add(area);
        area.setVisible(false);
        setor = new Setor();
        add(setor);
        setor.setVisible(false);
        usuario = new Usuario();
        add(usuario);
        usuario.setVisible(false);
        patrimonio = new Patrimonio(situacao, baixa, orgao);
        add(patrimonio);
        patrimonio.setVisible(false);
        transferencia = new Transferencia();
        add(transferencia);
        transferencia.setVisible(false);
        garantia = new Garantia();
        add(garantia);
        garantia.setVisible(false);
        emprestimo = new Emprestimo();
        add(emprestimo);
        emprestimo.setVisible(false);
        relatorioBem = new RelatorioBem();
        add(relatorioBem);
        relatorioBem.setVisible(false);
        relatorioTra = new RelatorioTra();
        add(relatorioTra);
        relatorioTra.setVisible(false);
        relatorioGar = new RelatorioGar();
        add(relatorioGar);
        relatorioGar.setVisible(false);
        relatorioEmp = new RelatorioEmp();
        add(relatorioEmp);
        relatorioEmp.setVisible(false);
        sobre = new Sobre();
        add(sobre);
        sobre.setVisible(false);
        termo = new TermoResponsabilidade();
        add(termo);
        termo.setVisible(false);
        preferencias = new Preferencias();
        add(preferencias);
        preferencias.setVisible(false);
        //Login
        login = new Login();
        login.setPai(this);
        login.setVisible(true);
    }

    private void deslogar() {
        if (janelaAberta!=null) {
            janelaAberta.setVisible(false);
        }
        daoUsuario.criarRegistro(usuarioLogado, "Efetuou logoff.");
        setVisible(false);
        login.setVisible(true);
    }

    private void abrirJanela(JInternalFrame janela) {
        ((JanelaPai)janela).reiniciar();
        janela.setVisible(true);
        if (janelaAberta!=null && !janelaAberta.equals(janela)) {
            janelaAberta.setVisible(false);
        }
        janelaAberta = janela;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        menuUsuario = new javax.swing.JMenu();
        subMenuPreferencias = new javax.swing.JMenuItem();
        subMenuDeslogar = new javax.swing.JMenuItem();
        subMenuSair = new javax.swing.JMenuItem();
        menuTabelas = new javax.swing.JMenu();
        subMenuFornecedores = new javax.swing.JMenuItem();
        subMenuGrupo = new javax.swing.JMenuItem();
        subMenuSubgrupo = new javax.swing.JMenuItem();
        subMenuArea = new javax.swing.JMenuItem();
        subMenuSetor = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuPatrimonio = new javax.swing.JMenu();
        subMenuCadPatri = new javax.swing.JMenuItem();
        subMenuConPatri = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        subMenuMovTra = new javax.swing.JMenuItem();
        subMenuMovMan = new javax.swing.JMenuItem();
        subMenuMovEmp = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        menuSobre = new javax.swing.JMenu();
        subMenuAjuda = new javax.swing.JMenuItem();
        subMenuSobre = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Manutenção de Patrimônios da Agecom");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        menuUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/usuario.png"))); // NOI18N
        menuUsuario.setText("Usuário");
        menuUsuario.setFont(new java.awt.Font("Segoe UI", 0, 15));

        subMenuPreferencias.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuPreferencias.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/preferencias.png"))); // NOI18N
        subMenuPreferencias.setText("Preferências");
        subMenuPreferencias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuPreferenciasActionPerformed(evt);
            }
        });
        menuUsuario.add(subMenuPreferencias);

        subMenuDeslogar.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuDeslogar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/logoff.png"))); // NOI18N
        subMenuDeslogar.setText("Deslogar");
        subMenuDeslogar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuDeslogarActionPerformed(evt);
            }
        });
        menuUsuario.add(subMenuDeslogar);

        subMenuSair.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/exit.png"))); // NOI18N
        subMenuSair.setText("Sair");
        subMenuSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuSairActionPerformed(evt);
            }
        });
        menuUsuario.add(subMenuSair);

        jMenuBar1.add(menuUsuario);

        menuTabelas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/tabelas.gif"))); // NOI18N
        menuTabelas.setText("Tabelas");
        menuTabelas.setFont(new java.awt.Font("Segoe UI", 0, 15));

        subMenuFornecedores.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuFornecedores.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/fornecedor.png"))); // NOI18N
        subMenuFornecedores.setText("Fornecedores");
        subMenuFornecedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuFornecedoresActionPerformed(evt);
            }
        });
        menuTabelas.add(subMenuFornecedores);

        subMenuGrupo.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuGrupo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/grupo_subgrupo.png"))); // NOI18N
        subMenuGrupo.setText("Grupo");
        subMenuGrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuGrupoActionPerformed(evt);
            }
        });
        menuTabelas.add(subMenuGrupo);

        subMenuSubgrupo.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuSubgrupo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/grupo_subgrupo.png"))); // NOI18N
        subMenuSubgrupo.setText("Subgrupo");
        subMenuSubgrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuSubgrupoActionPerformed(evt);
            }
        });
        menuTabelas.add(subMenuSubgrupo);

        subMenuArea.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuArea.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/departamento.png"))); // NOI18N
        subMenuArea.setText("Área");
        subMenuArea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuAreaActionPerformed(evt);
            }
        });
        menuTabelas.add(subMenuArea);

        subMenuSetor.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuSetor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/departamento.png"))); // NOI18N
        subMenuSetor.setText("Setor");
        subMenuSetor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuSetorActionPerformed(evt);
            }
        });
        menuTabelas.add(subMenuSetor);

        jMenuItem1.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/usuario.png"))); // NOI18N
        jMenuItem1.setText("Usuário");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menuTabelas.add(jMenuItem1);

        jMenuBar1.add(menuTabelas);

        menuPatrimonio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/patrimonio.png"))); // NOI18N
        menuPatrimonio.setText("Patrimônio");
        menuPatrimonio.setFont(new java.awt.Font("Segoe UI", 0, 15));

        subMenuCadPatri.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuCadPatri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cadastrar.gif"))); // NOI18N
        subMenuCadPatri.setText("Cadastrar patrimônio");
        subMenuCadPatri.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuCadPatriActionPerformed(evt);
            }
        });
        menuPatrimonio.add(subMenuCadPatri);

        subMenuConPatri.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuConPatri.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/buscar.png"))); // NOI18N
        subMenuConPatri.setText("Consultar patrimônio");
        subMenuConPatri.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuConPatriActionPerformed(evt);
            }
        });
        menuPatrimonio.add(subMenuConPatri);

        jMenuBar1.add(menuPatrimonio);

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/movimentacoes.png"))); // NOI18N
        jMenu1.setText("Movimentações");
        jMenu1.setFont(new java.awt.Font("Segoe UI", 0, 15));

        subMenuMovTra.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuMovTra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/transferencia.png"))); // NOI18N
        subMenuMovTra.setText("Transferência");
        subMenuMovTra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuMovTraActionPerformed(evt);
            }
        });
        jMenu1.add(subMenuMovTra);

        subMenuMovMan.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuMovMan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/garantia.gif"))); // NOI18N
        subMenuMovMan.setText("Manutenção/Garantia");
        subMenuMovMan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuMovManActionPerformed(evt);
            }
        });
        jMenu1.add(subMenuMovMan);

        subMenuMovEmp.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuMovEmp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/emprestimo.png"))); // NOI18N
        subMenuMovEmp.setText("Empréstimo");
        subMenuMovEmp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuMovEmpActionPerformed(evt);
            }
        });
        jMenu1.add(subMenuMovEmp);

        jMenuBar1.add(jMenu1);

        jMenu2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/relatorio.png"))); // NOI18N
        jMenu2.setText("Relatórios");
        jMenu2.setFont(new java.awt.Font("Segoe UI", 0, 15));

        jMenuItem2.setFont(new java.awt.Font("Segoe UI", 0, 15));
        jMenuItem2.setText("Relatório de Bens");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        jMenuItem3.setFont(new java.awt.Font("Segoe UI", 0, 15));
        jMenuItem3.setText("Relatório de Transferência");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuItem4.setFont(new java.awt.Font("Segoe UI", 0, 15));
        jMenuItem4.setText("Relatório de Garantia");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem4);

        jMenuItem5.setFont(new java.awt.Font("Segoe UI", 0, 15));
        jMenuItem5.setText("Relatório de Empréstimo");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuItem6.setFont(new java.awt.Font("Segoe UI", 0, 15));
        jMenuItem6.setText("Termo de Responsabilidade");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuBar1.add(jMenu2);

        menuSobre.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/ajuda.png"))); // NOI18N
        menuSobre.setText("Ajuda");
        menuSobre.setFont(new java.awt.Font("Segoe UI", 0, 15));

        subMenuAjuda.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuAjuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/manual.gif"))); // NOI18N
        subMenuAjuda.setText("Manual");
        subMenuAjuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuAjudaActionPerformed(evt);
            }
        });
        menuSobre.add(subMenuAjuda);

        subMenuSobre.setFont(new java.awt.Font("Segoe UI", 0, 15)); // NOI18N
        subMenuSobre.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/sobre.png"))); // NOI18N
        subMenuSobre.setText("Sobre");
        subMenuSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subMenuSobreActionPerformed(evt);
            }
        });
        menuSobre.add(subMenuSobre);

        jMenuBar1.add(menuSobre);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 792, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 542, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-800)/2, (screenSize.height-600)/2, 800, 600);
    }// </editor-fold>//GEN-END:initComponents

    private void subMenuFornecedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuFornecedoresActionPerformed
        abrirJanela(fornecedor);
}//GEN-LAST:event_subMenuFornecedoresActionPerformed

    private void subMenuGrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuGrupoActionPerformed
        abrirJanela(grupo);
    }//GEN-LAST:event_subMenuGrupoActionPerformed

    private void subMenuSubgrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuSubgrupoActionPerformed
        abrirJanela(subgrupo);
    }//GEN-LAST:event_subMenuSubgrupoActionPerformed

    private void subMenuAreaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuAreaActionPerformed
        abrirJanela(area);
    }//GEN-LAST:event_subMenuAreaActionPerformed

    private void subMenuSetorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuSetorActionPerformed
        abrirJanela(setor);
    }//GEN-LAST:event_subMenuSetorActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        if (usuarioLogado.getNivel()==2) {
            abrirJanela(usuario);
        } else {
            JOptionPane.showMessageDialog(null, "Você não tem acesso a esse item.");
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void subMenuDeslogarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuDeslogarActionPerformed
        deslogar();
    }//GEN-LAST:event_subMenuDeslogarActionPerformed

    private void subMenuSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuSairActionPerformed
        dispose();
    }//GEN-LAST:event_subMenuSairActionPerformed

    private void subMenuCadPatriActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuCadPatriActionPerformed
        if (janelaAberta instanceof Patrimonio) {
            if (janelaAberta.isVisible()) {
                patrimonio.mudarAba(0);
            } else {
                abrirJanela(patrimonio);
                patrimonio.mudarAba(0);                
            }
        } else {
            abrirJanela(patrimonio);
            patrimonio.mudarAba(0);
        }        
    }//GEN-LAST:event_subMenuCadPatriActionPerformed

    private void subMenuConPatriActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuConPatriActionPerformed
        if (janelaAberta instanceof Patrimonio) {
            if (janelaAberta.isVisible()) {
                patrimonio.mudarAba(1);
            } else {
                abrirJanela(patrimonio);
                patrimonio.mudarAba(1);                
            }
        } else {
            abrirJanela(patrimonio);
            patrimonio.mudarAba(1);
        }
    }//GEN-LAST:event_subMenuConPatriActionPerformed

    private void subMenuMovTraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuMovTraActionPerformed
        abrirJanela(transferencia);
    }//GEN-LAST:event_subMenuMovTraActionPerformed

    private void subMenuMovManActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuMovManActionPerformed
        abrirJanela(garantia);
    }//GEN-LAST:event_subMenuMovManActionPerformed

    private void subMenuMovEmpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuMovEmpActionPerformed
        abrirJanela(emprestimo);
    }//GEN-LAST:event_subMenuMovEmpActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        abrirJanela(relatorioBem);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        abrirJanela(relatorioTra);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        abrirJanela(relatorioGar);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        abrirJanela(relatorioEmp);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void subMenuAjudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuAjudaActionPerformed
        JOptionPane.showMessageDialog(null, "Ainda não implantado.");
    }//GEN-LAST:event_subMenuAjudaActionPerformed

    private void subMenuSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuSobreActionPerformed
        abrirJanela(sobre);
    }//GEN-LAST:event_subMenuSobreActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        daoUsuario.criarRegistro(usuarioLogado, "Efetuou logoff, forçadamente.");
    }//GEN-LAST:event_formWindowClosing

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        abrirJanela(termo);
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void subMenuPreferenciasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subMenuPreferenciasActionPerformed
        abrirJanela(preferencias);
}//GEN-LAST:event_subMenuPreferenciasActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new Principal();
                } catch (ParseException ex) {
                    Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenu menuPatrimonio;
    private javax.swing.JMenu menuSobre;
    private javax.swing.JMenu menuTabelas;
    private javax.swing.JMenu menuUsuario;
    private javax.swing.JMenuItem subMenuAjuda;
    private javax.swing.JMenuItem subMenuArea;
    private javax.swing.JMenuItem subMenuCadPatri;
    private javax.swing.JMenuItem subMenuConPatri;
    private javax.swing.JMenuItem subMenuDeslogar;
    private javax.swing.JMenuItem subMenuFornecedores;
    private javax.swing.JMenuItem subMenuGrupo;
    private javax.swing.JMenuItem subMenuMovEmp;
    private javax.swing.JMenuItem subMenuMovMan;
    private javax.swing.JMenuItem subMenuMovTra;
    private javax.swing.JMenuItem subMenuPreferencias;
    private javax.swing.JMenuItem subMenuSair;
    private javax.swing.JMenuItem subMenuSetor;
    private javax.swing.JMenuItem subMenuSobre;
    private javax.swing.JMenuItem subMenuSubgrupo;
    // End of variables declaration//GEN-END:variables

}
